
Page({
    data: {
        num:1,
        enable: true,
        liu: "刘怡童",
        list: [{
                name: "刘怡童",
                age: 21,
            },
            {
                name: "杨欣",
                age: 13,
            },
        ],
        objectArray: [
            { id: 5, unique: "unique_5" },
            { id: 4, unique: "unique_4" },
            { id: 3, unique: "unique_3" },
            { id: 2, unique: "unique_2" },
            { id: 1, unique: "unique_1" },
            { id: 0, unique: "unique_0" },
        ],
        numberArray: [1, 2, 3, 4],
    },
    addToFront: function() {
        const length = this.data.objectArray.length;
        this.data.objectArray = [{ id: length, unique: "unique_" + length }].concat(
            this.data.objectArray
        );
        this.setData({
            objectArray: this.data.objectArray,
        });
    },
    switch: function() {
        const length = this.data.objectArray.length;
        const x = Math.floor(Math.random() * length);
        const y = Math.floor(Math.random() * length);
        const temp = this.data.objectArray[x];
        this.data.objectArray[x] = this.data.objectArray[y];
        this.data.objectArray[y] = temp;
        this.setData({
            objectArray: this.data.objectArray,
        });
    },
    // 控制wx:if的函数
    change: function() {
        this.data.enable = !this.data.enable;
        this.setData({
            enable: this.data.enable,
        });
    },
    output: function(e) {
      console.log(e);
      this.data.num=e.detail.value
       this.setData({
         num:this.data.num
       })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {},

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
});